import React, {Component} from 'react';
import {Redirect, Route, Switch} from 'react-router-dom';
import {Layout} from 'antd';
import './app.less';
import SiderCustom from './SiderCustom';
import HeaderCustom from './HeaderCustom';

const {Content, Footer} = Layout;

export default class App extends Component {
    state = {
        collapsed: false,
    };
    toggle = () => {
        // this.setState({
        //     collapsed: !this.state.collapsed,
        // }, function () {
        //     setCookie("mspa_SiderCollapsed", this.state.collapsed);
        // });
    };

    componentDidMount() {
        //保存Sider收缩
        // if (getCookie("mspa_SiderCollapsed") === null) {
        //     setCookie("mspa_SiderCollapsed", false);
        // }
    }

    render() {
        const {collapsed} = this.state;
        const {location} = this.props;
        let name="zhangsan";
        
        // if (!getCookie("mspa_user") || getCookie("mspa_user") === "undefined") {
        //     return <Redirect to="/login"/>
        // } else {
        //     name = JSON.parse(getCookie("mspa_user")).username;
        // }

        return (
            <Layout className="ant-layout-has-sider" style={{height: '100%'}}>
                <SiderCustom collapsed={collapsed}/>
                <Layout>
                    <HeaderCustom collapsed={collapsed} toggle={this.toggle} username={name}/>
                    <Content style={{margin: '0 16px'}}>
                        
                    </Content>
                    <Footer style={{textAlign: 'center'}}>
                        MSPA ©2017-2018 Created by zysoft
                    </Footer>
                </Layout>
            </Layout>
        );
    }
}